// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SongFile.java

package presenter;

import java.awt.Color;
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;

// Referenced classes of package presenter:
//            SongVerse

public class SongFile
    implements Comparable
{

    public SongFile()
    {
        this("New Song");
        songNo = 0;
    }

    public SongFile(String title)
    {
        this.title = title;
        verses = new ArrayList();
        String input[] = {
            title
        };
        SongVerse sv = new SongVerse(input);
        verses.add(sv);
        hasVideo = false;
        customColor = false;
        scripture = false;
        customBackground = false;
    }

    public SongFile(File f)
    {
        aFile = f;
        readFile(f);
        hasVideo = false;
        scripture = false;
        customBackground = false;
        customColor = false;
    }

    public void setBackground(String back)
    {
        background = back;
        customBackground = true;
    }

    public String getBackground()
    {
        return background;
    }

    public boolean hasCustomBackground()
    {
        return customBackground;
    }

    public void setHasVideo(boolean b)
    {
        hasVideo = b;
    }

    public void setHasBackground(boolean b)
    {
        customBackground = b;
    }

    public void setColor(Color c)
    {
        color = c;
        customColor = true;
    }

    public boolean hasCustomColor()
    {
        return customColor;
    }

    public void setHasCustomColor(boolean custom)
    {
        customColor = custom;
    }

    public Color getColor()
    {
        return color;
    }

    public boolean isScripture()
    {
        return scripture;
    }

    public void setScripture(boolean b)
    {
        scripture = b;
    }

    public String getScriptureString()
    {
        return scriptureString;
    }

    public void setScriptureString(String input)
    {
        scriptureString = input;
    }

    public String getPath()
    {
        return aFile.getPath();
    }

    public void setVideo(String s)
    {
        hasVideo = true;
        video = s;
    }

    public boolean hasVideo()
    {
        return hasVideo;
    }

    public String getVideo()
    {
        return video;
    }

    public String toString()
    {
        return title;
    }

    public File getFile()
    {
        return aFile;
    }

    public int compareTo(Object f)
    {
        if(f instanceof SongFile)
        {
            SongFile file = (SongFile)f;
            return aFile.compareTo(file.getFile());
        } else
        {
            return -1;
        }
    }

    public void readFile(File f)
    {
        try
        {
            aFile = f;
            verses = new ArrayList();
            BufferedReader br = new BufferedReader(new FileReader(f));
            title = br.readLine();
            String nextLine = br.readLine();
            boolean middleOfVerse = false;
            ArrayList verse = new ArrayList();
            do
            {
                if(nextLine == null)
                    break;
                Scanner sc = new Scanner(nextLine);
                if(sc.hasNext())
                {
                    if(nextLine.contains("CCLI Song No."))
                    {
                        songNo = Integer.parseInt(nextLine.substring(14, nextLine.length()));
                        break;
                    }
                    middleOfVerse = true;
                    verse.add(nextLine);
                } else
                if(middleOfVerse)
                {
                    middleOfVerse = false;
                    SongVerse sv = new SongVerse((String[])verse.toArray(new String[1]));
                    verses.add(sv);
                    verse = new ArrayList();
                }
                nextLine = br.readLine();
            } while(true);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public String[] getVerse(int i)
    {
        return ((SongVerse)verses.get(i)).getLyrics();
    }

    public String getVerseType(int i)
    {
        return ((SongVerse)verses.get(i)).getType();
    }

    public int getNumberOfVerses()
    {
        return verses.size();
    }

    public SongVerse[] getVerses()
    {
        return (SongVerse[])verses.toArray(new SongVerse[1]);
    }

    public void setVerses(SongVerse verses[])
    {
        this.verses = new ArrayList();
        for(int i = 0; i < verses.length; i++)
            this.verses.add(verses[i]);

    }

    public int getNumber()
    {
        return songNo;
    }

    public String getOneLine()
    {
        String x = "";
        SongVerse verse[] = (SongVerse[])verses.toArray(new SongVerse[1]);
        for(int i = 0; i < verse.length; i++)
        {
            if(!verse[i].getType().equals(""))
                x = (new StringBuilder()).append(x).append(verse[i].getType()).append("\n").toString();
            String lyrics[] = verse[i].getLyrics();
            for(int j = 0; j < lyrics.length; j++)
            {
                x = (new StringBuilder()).append(x).append(lyrics[j]).toString();
                x = (new StringBuilder()).append(x).append("\n").toString();
            }

            x = (new StringBuilder()).append(x).append("\n").toString();
        }

        return x;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public static void main(String args[])
    {
        File f = new File("/home/alamarre/downloads/You_Are_My_King.txt");
        SongFile sf = new SongFile(f);
        for(int i = 0; i < sf.getNumberOfVerses(); i++)
        {
            String type = sf.getVerseType(i);
            String temp[] = sf.getVerse(i);
            for(int j = 0; j < temp.length; j++);
        }

    }

    private File aFile;
    private ArrayList verses;
    private int songNo;
    private String title;
    private String video;
    private boolean hasVideo;
    private boolean scripture;
    private String scriptureString;
    private String background;
    private boolean customBackground;
    private boolean customColor;
    private Color color;
}
